/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__jolt_frtime2datetimestr.c                       */
/*  NOTE      =                                                    */
/*  DATE      = 2016/03/01 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"

#include "../../../src/module/tuxedojolt/config.h"
#include <tuxedojolt/jolt_comm.h>

extern int __jolt_frtime2datetimestr(struct timeval *p_tv
                                    , char *p_time
                                    , unsigned int ui_time_size);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    struct timeval st_timestamp;
    st_timestamp.tv_sec = 1454549354L;
    st_timestamp.tv_usec = 123456L;
    char arr_buff[64];
    __jolt_frtime2datetimestr(&st_timestamp, arr_buff, sizeof(arr_buff));
    CU_ASSERT_STRING_EQUAL(arr_buff, "2016-02-04 09:29:14.123456");
}

int add_suite__jolt_frtime2datetimestr(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __jolt_frtime2datetimestr()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
